package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.domain.Book;
import com.itheima.service.HelloService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hello")
public class HelloController {
    @Reference
    private HelloService helloService;

    @RequestMapping("/sayHello")
    public String sayHello(){
        System.out.println(123);
        return helloService.sayHello();
    }

    @RequestMapping("/findAll")
    public List<Book> findAll(){
        System.out.println("controller来了........");
        List<Book> bookList = helloService.findAll();
        System.out.println(bookList);
        return bookList;
    }

    @RequestMapping("/update")
    public void update(){
        System.out.println("controller来了........");
        Book book=new Book(1,"童话镇","陈一发","中国人民出版社",37.30,2);
        helloService.update(book);

    }
}
